package com.zeng.jiudian.servlet.front;

import com.alibaba.fastjson.JSONObject;
import com.zeng.jiudian.bean.*;
import com.zeng.jiudian.service.*;
import com.zeng.jiudian.service.impl.*;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @Author JJ_yo
 * @Date 2020/8/1 - 11:28
 */
@WebServlet("/callUs")
public class CallUsServlet extends HttpServlet
{
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
    {
        //展示部分
        ShowService showService = new ShowServiceImpl();
        List<ShowModel> list = showService.findUnion();
        ShowModel model = null;
        if (list.size() > 0)
        {
            model = list.get(0);
        }

        //产品种类
        ProductTypeService productTypeService = new ProductTypeServiceImpl();
        List<ProductTypeModel> productTypeList = productTypeService.getAll();

        //酒店信息
        HotelService hotelService = new HotelServiceImpl();
        HotelModel hotel = hotelService.getAll();

        JSONObject jsonObject = new JSONObject();
        jsonObject.put("model", model);
        jsonObject.put("productTypeList", productTypeList);
        jsonObject.put("hotel", hotel);
        resp.getWriter().println(jsonObject);
    }
}
